package com.eastfair.projectcore.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 菜单
 * </p>
 *
 * @author ligang
 * @date 2021-10-28
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "MenuTerminalTypeEnum", description = "场景类型 #{WEB:PC页面;APP:APP;MINI_PROGRAMS:小程序-枚举")
public enum MenuTerminalTypeEnum implements BaseEnum {

    /**
     * WEB="PC页面"
     */
    WEB("PC页面"),
    /**
     * APP="APP"
     */
    APP("APP"),
    /**
     * MINI_PROGRAMS="小程序"
     */
    MINI_PROGRAMS("小程序"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static MenuTerminalTypeEnum match(String val, MenuTerminalTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static MenuTerminalTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(MenuTerminalTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "WEB,APP,MINI_PROGRAMS", example = "WEB")
    public String getCode() {
        return this.name();
    }

}
